#include "thread_cpp11.h"

CThreadCpp11::CThreadCpp11()
{}

CThreadCpp11::~CThreadCpp11()
{}

void CThreadCpp11::init()
{
    m_sp_send_thread.reset(new std::thread(std::bind(&CThreadCpp11::netThreadProc, this)));
    m_sp_recv_thread.reset(new std::thread(std::bind(&CThreadCpp11::netThreadProc, this)));
}

void CThreadCpp11::start()
{
    m_stopped = false;
    m_sp_thread.reset(new std::thread(&CThreadCpp11::threadProc, this, 888, 999));
}

void CThreadCpp11::stop()
{
    m_stopped = true;
    if (m_sp_thread) {
        if (m_sp_thread->joinable()) {
            m_sp_thread->join();
        }
    }
}

void CThreadCpp11::threadProc(int arg1, int arg2)
{
    while (!m_stopped) {
        printf("thread function use instance method.\n");
        std::this_thread::sleep_for(std::chrono::milliseconds(500));
    }
}

void CThreadCpp11::netThreadProc()
{}